function [OutPointInArea,Num_EndPathPoint]=EmapInArea(OutPoint_x,OutPoint_y,PathPoint_X,PathPoint_Y,PathPoint_yaw,Nr_VldPathPoint)

car_length=4.588*1000;
car_width=1.878*1000;
VehicleRearYaw=zeros(length(PathPoint_yaw),1);
rear_sus=0.974*1000;

OutPointInArea=uint8(zeros(length(OutPoint_x),1));
% New_OutPointX = int16(zeros(length(OutPoint_x),1));
% New_OutPointY = int16(zeros(length(OutPoint_y),1));
Num_EndPathPoint=1;
RLx=zeros(300,1);
RLy=zeros(300,1);
%%
%求出PathPoint倾斜角度
for i=1:Nr_VldPathPoint
    VehicleRearYaw(i) = PathPoint_yaw(i) - pi/2;
    RLx_part1=PathPoint_X(i);
    RLx_part2=rear_sus*cos(PathPoint_yaw(i));
    RLx_part3=0.5*car_width*sin(PathPoint_yaw(i));
    
    %     RLx(i) = PathPoint_X(i) - rear_sus*cos(PathPoint_yaw(i)) - 0.5*car_width*sin(PathPoint_yaw(i));
    RLx(i) = RLx_part1 - RLx_part2 - RLx_part3;
    RLx_index=RLx(i);
    RLy(i) = PathPoint_Y(i) - rear_sus*sin(PathPoint_yaw(i)) + 0.5*car_width*cos(PathPoint_yaw(i));
    RLy_index=RLy(i);
    for j=1:length(OutPoint_x)
        OutPointXAfterOffset= OutPoint_x(j)-RLx_index;
        OutPointYAfterOffset= OutPoint_y(j)-RLy_index;
        Yaw_Offset = VehicleRearYaw(i);
        [New_OutPointXAfterOffset ,New_OutPointYAfterOffset,b_OutPointInArea]=CalOutPointPos(OutPointXAfterOffset, OutPointYAfterOffset,Yaw_Offset);
        OutPointInArea(j)=b_OutPointInArea;
        New_OutPointX = int16(New_OutPointXAfterOffset);
        New_OutPointY = int16(New_OutPointYAfterOffset);
        if b_OutPointInArea==uint8(1)
            break
        end
        
    end
    Num_EndPathPoint=i-1;
    if OutPointInArea(j)==1
        break
    end
end



    function [New_OutPointX ,New_OutPointY,b_OutPointInArea]=CalOutPointPos(OutPointX, OutPointY ,Yaw_Offset)
        OutPointX=single(OutPointX);
        OutPointY=single(OutPointY);
        OutPointLength = sqrt(OutPointX^2 + OutPointY^2);
        OutPointYaw = atan2(OutPointY,OutPointX);
        New_OutPointYaw = OutPointYaw - Yaw_Offset;
        New_OutPointY=sin(New_OutPointYaw) * OutPointLength;
        New_OutPointX=cos(New_OutPointYaw) * OutPointLength;
        if (0<New_OutPointX&&New_OutPointX<car_width) && (0<New_OutPointY&&New_OutPointY<car_length)
            b_OutPointInArea=uint8(1);
        else
            b_OutPointInArea=uint8(0);
        end
    end
end


